<template>
    <div class="cost-page">
        <div class="video-page" v-if="systemShow">
            <Row type="flex" justify="center" align="middle" class="video-page-row">
                <Col class="video-top">
                    <video :src="video" controls="controls" class="video"></video>
                </Col>
                <Col>
                    <Button type="primary" @click="inSystem">进入系统</Button>
                </Col>
            </Row>
        </div>
        <div class="content" v-if="!systemShow">
            <div class="content-form">
                <Form ref="formValidate" :model="formValidate" :label-width="200">
                    <FormItem label="盈亏平衡点" prop="name">
                        <Input v-model="formValidate.win" placeholder=""></Input>
                    </FormItem>

                    <FormItem label="市场需求弹性" prop="name">
                        <Input v-model="formValidate.market" placeholder=""></Input>
                    </FormItem>

                    <FormItem>
                        <Button type="primary" @click="getSumPrice" :loading="loading1">保存</Button>
                        <Button type="primary" to="/school/set-money" style="margin-left: 10px" :disabled="button">下一步
                        </Button>
                    </FormItem>
                </Form>
            </div>
        </div>
    </div>
</template>

<script>
import { saveStudentConten } from '@/api/school'
import { mapActions } from 'vuex'

export default {
  data () {
    return {
      loading1: false,
      systemShow: false,
      button: true,
      animal: '',
      formValidate: {
        win: '',
        market: ''
      }
    }
  },
  methods: {
    ...mapActions([
      'setHelpId'
    ]),
    inSystem () {
      this.systemShow = false
    },
    getSumPrice () {
      if (this.formValidate.win === '') {
        this.$Message.error('请输入盈亏平衡点！')
        return false
      }
      if (this.formValidate.market === '') {
        this.$Message.error('请输入市场需求！')
        return false
      }
      this.loading1 = true
      let data = { type: '5', content6: this.formValidate.win, content7: this.formValidate.market }
      saveStudentConten(data).then(ret => {
        if (ret.data.errcode === 1001) {
          this.$Message.success('保存成功')
          this.loading1 = false
          this.button = false
        } else {
          this.$Message.error({
            content: '保存失败,\n' + ret.data.errmsg
          })
        }
      })
    }
  },
  mounted () {
    this.setHelpId(5)
  }
}
</script>

<style scoped lang="less">
    .cost-page {
        .content {
            width: 800px;

            &-top {
                margin-left: 40%;
            }

            &-form {
                margin-top: 20px;
            }
        }
    }

    .video-page {
        &-row {
            flex-direction: column;
        }
    }

    .video-top {
        .video {
            height: 400px;
        }
    }
</style>
